﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace WindowsTopshelfService45
{
    public class MyWorker
    {
        public void Start()
        {
            //To do something
            Task.Factory.StartNew(async () =>
            {
                HttpClient client = new HttpClient();
                while (true)
                {
                    Thread.Sleep(1000 * 2);
                    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "：" + Guid.NewGuid().ToString());
                    await client.GetAsync("https://www.baidu.com/");
                }
            }, TaskCreationOptions.LongRunning);
        }
        public void Stop()
        {
            //To do something
        }
    }
}
